package com.bsh.repository;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.bsh.mybatis.IRepository.RoleModuleMapper;
import com.bsh.mybatis.model.RoleModule;

@Repository
public class DaoRoleModule {
	@Resource
	SqlSessionTemplate session; 
	RoleModuleMapper getMapper(){
		return session.getMapper(RoleModuleMapper.class);
	}
		
	public int deleteByPrimaryKey(Integer id) {
		int res = getMapper().deleteByPrimaryKey(id);
		return res;
	}

	public int insert(RoleModule record) {
		int res = getMapper().insert(record);
		return record.getId();
	}

	public int insertSelective(RoleModule record) {
		int res = getMapper().insertSelective(record);
		return record.getId();
	}

	public RoleModule selectByPrimaryKey(Integer id) {
		RoleModule row = getMapper().selectByPrimaryKey(id);
		return row;
	}

	public int updateByPrimaryKeySelective(RoleModule record) {
		int res = getMapper().updateByPrimaryKeySelective(record);
		return res;
	}

	public int updateByPrimaryKey(RoleModule record) {
		int res = getMapper().updateByPrimaryKey(record);
		return res;
	}

	
	/**
	 * 读取角色的模块列表 
	 * @param roleId
	 */
	public List<RoleModule> getRolePermission(int roleId){
		List<RoleModule> res = getMapper().getRolePermission(roleId);
		return res;
	}	
	
	/**
	 * 按角色删除 
	 * @param roleId
	 */
	public int removeByRole(int roleId){
		return getMapper().removeByRole(roleId);
	}
}
